<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class HandleRecord extends AdminController{
	public $_validation = null;
	
	function __construct(){
	    date_default_timezone_set('Asia/Shanghai');
		parent::__construct();
		$this->load->model('MHandleRecord');
		$this->pay_status_css = array(
				'0'=>'label label-sm label-default',
				'1'=>'label label-sm label-success'
		);
		$this->transfer_status_css = array(
				'0'=>'label label-sm label-default',
				'1'=>'label label-sm label-success',
				'2'=>'label label-sm label-warning'
		);
	}
	
	function index($game_tag=null){
		$this->output->enable_profiler(TRUE);
		//$this->load->model('MUser');
		$this->load->library('FormFilter');
		$this->load->helper('formfilter');
		$this->formfilter->addFilter('withdraw_no', 'where');
		$this->formfilter->addFilter('user_id','where');
		$this->formfilter->addFilter('user.account','where');
		$this->formfilter->addFilter('handle_type','where');
		
		$limit = $this->pagination($this->MHandleRecord->getCount());
		
		$list = $this->MHandleRecord->getList($limit);
		$this->assign('list', $list);
		$this->layout();
	}
	
	
	function view($id){
	       
	    if(!$this->p->edit){
	        //权限不足
	        show_error(l('user_has_nopower'));
	    }
		if(!is_numeric($id)){
			show_error(l('id_not_null'));
		}
		$obj = $this->MSelfBankOrder->getOne(Array('id'=>$id));
		if(!$obj){
			errorAndRedirect('未找到定义！');
		}
		$this->assign('order', $obj);
		$this->layout('view');
	}
	
	
	function delete($id, $update_time){
		if(!is_numeric($id) || !is_numeric($update_time)){
			show_error(l('id_not_null'));
		}
		$this->load->model('MGameTags');
		
		$this->db->trans_start();
		if(!$this->MGame->delete($id, $update_time)){
			$this->db->_trans_status = FALSE;
		}
		if(!$this->MGameTags->deleteGameId($id)){
			$this->db->_trans_status = FALSE;
		}
		$this->db->trans_complete();
		if($this->db->trans_status()!==FALSE){
			successAndRedirect(l('delete_success'));
		}else{
			errorAndRedirect(l('data_fail'));
		}
		
	}
	
	
}